import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * http状态码302(重定向)
 */
public class S8_T1Servlet extends HttpServlet {

    //把doGet和goPost()合并处理
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //如果有一个请求来了
        //重定向到hi.html
        //(1)返回302状态码 (2)响应头Location:/hi.html
        resp.sendRedirect("/servlet/hi.html");
    }
}
